﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Badminton
{
    public partial class RegisterOperatorForm : Form
    {
        public RegisterOperatorForm()
        {
            InitializeComponent();
        }

        private void btnCancelfm_Click(object sender, EventArgs e)
        {
            this.Close();
            FormLogin fl = new FormLogin();
            fl.Show();
        }

        private void btnCommitOperator_Click(object sender, EventArgs e)
        {
            //用户输入的必须信息不为空
            if (this.txtOperatorName.Text== null||txtCertification.Text== null
                ||this.comboxPower.SelectedItem==null)
            {

                MessageBox.Show("你输入的信息：  用户名、证件号码、权限  不能为空", ">>>>>不能为空", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (this.txtPwd.Text.Trim().Equals(this.txtRePwd.Text.Trim()))
                {
                     Model.Operator op = new Model.Operator(this.txtOperatorName.Text.Trim(),this.txtPwd.Text.Trim(),txtCertification.Text.Trim(),
                                                   txtTel.Text.Trim(),Convert.ToInt32(this.comboxPower.SelectedItem.ToString()));
                    if (BLL.BllOperater.RegisterOperator(op))
                    {
                        MessageBox.Show("恭喜你，注册成功…………", ">>>>>注册成功", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else 
                    {
                        MessageBox.Show("你不能注册，请稍后再来……", ">>>>>注册失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("你再次输入的密码不正确，请重新输入……", ">>>>>确认密码错误", MessageBoxButtons.OK, MessageBoxIcon.Error); 
                }
            
            }

        }
    }
}